package test.arch.chameleon.tools;

import static org.junit.Assert.*;

import java.io.File;

import org.apache.commons.lang3.SystemUtils;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import arch.chameleon.tools.decode.Base64DecoderBatch;

/**
 * @author George
 *
 */
public class Base64DecoderBatchTestcase {

	private transient Logger log = LoggerFactory.getLogger(this.getClass());
	
	/**
	 * 测试批量文本解码
	 */
	@Test
	public void decodeToOneBinFileViaText(){
		try{
			Base64DecoderBatch.decodeToOneBinFile(
					new File(SystemUtils.getUserDir() + "/target/codes/"), 
					new File(SystemUtils.getUserDir() + "/target/bin/bin.rar")
			);		
		}catch(Throwable t){
			log.error(t.getMessage(), t);
			fail();
		}
		
		
	}
	
	
	/**
	 * 测试数据库SQLite的批量解码
	 */
	@Test
	public void decodeToOneBinFileViaSQLite(){
		try{
			Base64DecoderBatch.decodeToOneBinFile(SystemUtils.getUserDir() + "/target/codes/barcode_scanner_history.db", 
					"select text from history", new File(SystemUtils.getUserDir() + "/target/bin/bin.rar"));
		}catch(Throwable t){
			log.error(t.getMessage(), t);
			fail();
		}	
	}
	
}
